# 1为ARJ 111架机，2为C919 104架机
import pandas as pd
# 打开文件
# path = r'E:\试飞数据\处理后ADS-B数据\20241014\ADSB2024-10-14(B001E).txt'
from pandas import DataFrame
# 设置读取和存储路径
file_com = '20241022'
file = 'FTC-A700-00111-0085-A'
## 111架机WQAR数据
WQAR_file_name = 'B-3328_20241021082312'

#读取路径
path = r'E:\试飞数据\WQAR数据\原始数据' + '\\' + file + '\\' + WQAR_file_name + '.txt'

#设置读取数据列表
read_list = ['A_IOC_15L_150_CLOCK_150_UTC_HOURS_BNR','A_IOC_15L_150_CLOCK_150_UTC_MINUTES_BNR','A_IOC_15L_150_CLOCK_150_UTC_SECONDS_BNR','A_IOC_17L_171_COMPUTED_AIRSPEED']

## 存储参数列表
save_list = ['A_IOC_17L_171_COMPUTED_AIRSPEED']
# 读取数据
df = pd.read_csv(path,sep = '\t',usecols= read_list)  #读取指定参数
# df = pd.read_csv(path,sep = '\t')  #读取所有数据

df['bj_time'] = (df['A_IOC_15L_150_CLOCK_150_UTC_HOURS_BNR']+8)*3600 + df['A_IOC_15L_150_CLOCK_150_UTC_MINUTES_BNR']*60 + df['A_IOC_15L_150_CLOCK_150_UTC_SECONDS_BNR']

df['is_dumplicated'] = df.duplicated(subset=['bj_time'])

df.loc[df.is_dumplicated == True, 'bj_time'] += 0.5
df['bj_time'] = pd.to_datetime(df['bj_time'], unit = 's')

df = df.set_index('bj_time')

df.index = df.index.strftime("%H:%M:%S:%f")

df_result = df[read_list]

path_out = r'E:\试飞数据\双机试飞数据'+ '\\'+ file_com + '\\' + WQAR_file_name+'_WQAR.txt'

df_result.to_csv(path_out, sep='\t')
